/*
 * @Author: axe
 * @Email: hedgehogee@sina.com
 * @Date: 2023-04-14 16:36:34
 * @Last Modified by: axe
 * @Last Modified time: 2023-04-14 18:28:28
 */

// 主语言
// window.navigator.language(s)
const locale = import.meta.env.VITE_LOCALE_LANG

// 备选语言
const fallbackLocale = import.meta.env.VITE_LOCALE_FALLBACK_LANG

// 货币 i18n
// https://tc39.es/ecma402/#numberformat-objects
// export const numberFormats = {}

// 日期 i18n
// https://tc39.es/ecma402/#datetimeformat-objects
// export const datetimeFormats = {}

const locales = import.meta.glob('./*.json', { eager: true })
const messages: Record<string, any> = {}

Object.keys(locales).forEach(filePath => {
  const reg = /\.\/([a-z]*)\.json$/
  const key = filePath.match(reg)![1]

  messages[key] = locales[filePath]
})

export default { locale, fallbackLocale, messages, legacy: false }